package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 房间朝向枚举类
 * @author hans.zhang
 */
@Getter
@AllArgsConstructor
public enum DeviceTypeEnum {
    HOTWATER("1","hot_watermeter"),
    COLDWATER("2","cold_watermeter"),
    AMMETER("3","ammeter"),
    DOORLOCK("4","doorlock"),
    PAY_MODE_BEHIND("5","后付费"),
    PAY_MODE_FRONT("6","预付费"),
    HOTWATER_FEE_TYPE("7","热水费"),
    COLDWATER_FEE_TYPE("8","冷水费"),
    AMMETER_FEE_TYPE("9","电费"),
    ;
    private String value;
    private String name;

    public static String getValueByName(String name) {
        DeviceTypeEnum towardEnum = Arrays.stream(DeviceTypeEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(towardEnum != null,"TowardEnum类型:{}不存在",name);
        return towardEnum.getValue();
    }

    public static String getNameByValue(String value) {
        DeviceTypeEnum towardEnum = Arrays.stream(DeviceTypeEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(towardEnum != null,"TowardEnum类型:{}不存在",value);
        return towardEnum.getName();
    }

}
